#!/usr/bin/env python3.10
# -*- encoding: utf-8 -*-
'''
@File    :   schema.py
@Time    :   2024/01/02 15:28:07
@Author  :   windstarry 
@Version :   1.0
'''
# here put the import lib
from ninja import Schema, Field, ModelSchema
from system.models import Users

# 用户登录请求字段
class LoginSchema(Schema):
    username: str = Field(..., description="用户名")
    password: str = Field(..., description="密码")

    
# 用户注册请求字段
class RegisterSchema(Schema):
    username: str = Field(..., description="用户名")
    password: str = Field(..., description="密码")
    repassword: str = Field(..., description="重复密码")
    

class UserInfo(ModelSchema):
    class Config:
        model = Users
        # 包含的字段
        model_fields = ['id', 'username', 'nickname', 'email', 'user_pic']


class LoginResult(Schema):
    token: str


class UserSchema(Schema):
    userInfo: UserInfo

    
class PassWordSchemaIn(Schema):
    new_pwd: str = Field(..., description="新密码")
    old_pwd: str = Field(..., description="原密码")
    re_pwd: str = Field(..., description="重复密码")
    
    
class UpdateUserInfo(Schema):
    id: int = Field(..., description="用户id")
    nickname: str = Field(..., description="昵称")
    email: str = Field(..., description="邮箱")
    
    
class AvatarSchema(Schema):
    avatar: str = Field(..., description="头像")

    
    
